import {
  HomeOutlined,
  ShopOutlined,
  TeamOutlined,
  SafetyCertificateOutlined,
  KeyOutlined,
  CustomerServiceOutlined,
  BarChartOutlined,
  FileTextOutlined,
  SettingOutlined,
  UserOutlined,
  CloudOutlined,
  BellOutlined,
  MenuFoldOutlined,
  MenuUnfoldOutlined,
  LogoutOutlined,
} from '@ant-design/icons';
import React from 'react';

/**
 * 图标映射表
 */
const iconMap: Record<string, React.ComponentType<any>> = {
  HomeOutlined,
  ShopOutlined,
  TeamOutlined,
  SafetyCertificateOutlined,
  KeyOutlined,
  CustomerServiceOutlined,
  BarChartOutlined,
  FileTextOutlined,
  SettingOutlined,
  UserOutlined,
  CloudOutlined,
  BellOutlined,
  MenuFoldOutlined,
  MenuUnfoldOutlined,
  LogoutOutlined,
};

/**
 * 根据图标名称获取图标组件
 */
export const getIconComponent = (iconName: string): React.ComponentType<any> => {
  const IconComponent = iconMap[iconName];
  if (!IconComponent) {
    console.warn(`图标组件未找到: ${iconName}`);
    return HomeOutlined; // 默认图标
  }
  return IconComponent;
};

/**
 * 渲染图标组件
 */
export const renderIcon = (iconName: string, props?: any): React.ReactElement => {
  const IconComponent = getIconComponent(iconName);
  return React.createElement(IconComponent, props);
}; 